package com.framework.loippi.service.impl;

import com.framework.loippi.support.Page;
import com.framework.loippi.support.Pageable;
import com.framework.loippi.utils.Paramap;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.framework.loippi.dao.DoctorDao;
import com.framework.loippi.entity.Doctor;
import com.framework.loippi.service.DoctorService;

import java.util.Collections;
import java.util.List;
/**
 * SERVICE - Doctor(医生表)
 * 
 * @author wmj
 * @version 2.0
 */
@Service
public class DoctorServiceImpl extends GenericServiceImpl<Doctor, Long> implements DoctorService {
	
	@Autowired
	private DoctorDao doctorDao;
	
	
	@Autowired
	public void setGenericDao() {
		super.setGenericDao(doctorDao);
	}

	public List<Doctor> findListByPage(Object parameter){
		return doctorDao.findListByPage(parameter);
	}

	public Long deletes(Object parameter){
		return doctorDao.deletes( parameter);
	}

	@Override
	public List<Doctor> findListByDeId(Integer departmentId) {
		return doctorDao.findListByDeId(departmentId);
	}

	@Override
	public boolean phoneExists(String phone) {
		List<Doctor> doctors = doctorDao.findByParams(Paramap.create().put("phone", phone));
		return CollectionUtils.isNotEmpty(doctors);
	}

	@Override
	public Doctor findByPhone(String phone) {
		return doctorDao.findByPhone(phone);
	}
}
